<template>
	<view>
		<image :src="img"></image>
		<view class="con title">
			<view>{{title}}</view>
			<view>
				<view>学生会</view>
				<view>韩梅梅</view>
			</view>
		</view>
		<view class="con time">
			<view>报名时间：{{registration_start_time | format}}-{{registration_end_time | format}}</view>
			<view>活动时间：{{active_start_time | format}}-{{active_end_time | format}}</view>
		</view>
		<view class="con content">
			<text>{{content}}</text>
			
		</view>
		
		<view class="con foot">
			<view>时间:{{active_start_time | format}}</view>
			<view>{{title}}</view>
			<view>地点:{{address}}</view>
			<view>
				<button open-type="share" @click="share">分享给微信好友</button>
				<view @click="signUp">马上报名</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			id:0,
			content:'',
			img:'',
			title:'',
			address:'',
			active_end_time:"",
			active_start_time:'',
			registration_end_time:'',
			registration_start_time:'',
			wx_user_id:0
		};
	},
	onShareAppMessage(res) {
		if (res.from === 'button') {
			// 来自页面内分享按钮
			console.log('111111111', res.target);
		}
		return {
			title: '活动',
			path: '/pages/activity/detailed/detailed'
		};
	},
	created(){
		uni.getStorage({
			key: 'myInfo',
			success: res => {
				// console.log(res)
				this.wx_user_id=res.data.id
			}
		});
		uni.getStorage({
			key: 'value1',
			success: res => {
				// console.log(res.data),
				this.id=res.data.active_id,
				this.content=res.data.active_details,
				this.img=res.data.active_main_picture,
				this.title=res.data.active_title,
				this.address=res.data.address,
				this.active_end_time=res.data.active_end_time,
				this.active_start_time=res.data.active_start_time,
				this.registration_end_time=res.data.registration_end_time,
				this.registration_start_time=res.data.registration_start_time
			}
		});
	},
	filters: {
		format(value) {
			let date = new Date(value);
			let y=date.getFullYear();
			let m=date.getMonth()+1;
			let d=date.getDate();
			return y + '年' + (m < 10 ? '0' + m : m ) + '月' + (d < 10 ? '0' + d : d)+'日';
		}
	},
	methods: {
		share() {
			console.log(1);
			uni.share({
				provider: 'weixin',
				scene: 'WXSceneSession',
				type: 5,
				imageUrl: 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/962fc340-4f2c-11eb-bdc1-8bd33eb6adaa.png',
				title: '欢迎参加活动',
				miniProgram: {
					id: 'wxee4db3ec9c618898',
					path: 'pages/index/index',
					type: 0,
					webUrl: 'http://uniapp.dcloud.io'
				},
				success: ret => {
					console.log(JSON.stringify(ret));
				},
			});
		},
		async signUp(){
			console.log(this.id,this.wx_user_id)
			const {data:res} = await this.$http({
				url:'/activites/addRegistration',
				data:{
					campus_activites_id:this.id,
					wx_user_id:this.wx_user_id
				}
			});
			uni.reLaunch({
				url:'/pages/activity/activity'
			})
		}
	}

};
</script>

<style lang="less">
image {
	width: 750rpx;
	height: 326rpx;
}
.con {
	width: 690rpx;
	margin: 0 auto;
}
.title {
	width: 690rpx;
	height: 190rpx;
	display: flex;
	flex-direction: column;
	justify-content: space-around;
	> view:first-child {
		font-size: 44rpx;
		font-weight: bold;
	}
	> view:last-child {
		display: flex;
		> view:first-child {
			font-size: 24rpx;
			width: 100rpx;
			height: 36rpx;
			background-color: #eaeaea;
			color: #b4b3b3;
			margin-right: 20rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 10rpx;
		}
		> view:last-child {
			font-size: 26rpx;
			font-weight: bold;
		}
	}
}
.time {
	color: #b4b3b3;
	font-size: 26rpx;
	border: 2rpx dashed #b4b3b3;
	width: 690rpx;
	height: 140rpx;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
}
.content {
	width: 690rpx;

	> text {
		display: flex;
		align-items: center;
		width: 690rpx;
		padding: 22rpx 0;
		font-size: 28rpx;
		line-height: 62rpx;
		font-weight: bold;
	}
}

.content1 {
	margin-bottom: 40rpx;
	> text {
		line-height: 64rpx;
		color: #717171;
	}
}
.foot {
	font-size: 27rpx;
	font-weight: bold;
	line-height: 64rpx;
	> view:last-child {
		display: flex;
		justify-content: space-between;
		margin: 20rpx 0;
		view,button {
			width: 328rpx;
			height: 80rpx;
			border-radius: 40rpx;
			border: 2rpx solid #171717;
			font-size: 32rpx;
			font-weight: bold;
			display: flex;
			justify-content: center;
			align-items: center;
		}
		view:last-child {
			width: 328rpx;
			height: 80rpx;
			background-color: #f9cc66;
		}
	}
}
</style>
